<template>
	<view @touchmove.prevent>

		<uni-popup ref="popup" type="center">
			<!-- <view class="main"> -->
			<view class="main_box">
				<view class="main_box_d">
					<view class="title">中奖名单</view>
					<view class="name_list">
						<view class="name_list_head">账号</view>
						<view class="name_list_detail">
							<scroll-view class="scroll_view" scroll-y="true" @scrolltolower="scrolltolower">
								<view class="detail_ls" v-for="(item,index) in list" :key="index">{{item.customerName}}
								</view>
							</scroll-view>
						</view>
					</view>
					<view class="button_box">
						<image src="@/static/blindbox/jackpot/button.png" mode="" @click="back"></image>
					</view>
				</view>
			</view>
			<!-- </view> -->
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name: "winner-list",
		props: {
			// isShow: {
			// 	type: Boolean,
			// 	default: false,
			// },
			// id:{
			// 	type: String,
			// 	default: '',
			// },
		},
		data() {
			return {
				isShow: false,
				jackpotId: '', //
				list: [],
				pageNumber: 1, //当前页数
				pageSize: 10, //分页大小
				listTotal: 0, //列表总数
			};
		},
		beforeUpdate() {
			// uni.showLoading()
		},
		methods: {
			async getList() { //获取中奖名单
				uni.showLoading()
				let data = {
					jackpotId: this.jackpotId,
					pageNum: this.pageNumber,
					pageSize: this.pageSize,
				}
				const res = await this.$api.getJackpotRecordList(data);
				this.listTotal = res.result.total
				// if (this.pageNumber >= Math.ceil(this.listTotal / this.pageSize)) {
				// 	this.lodingtype=1
				// } else {
				// 	this.lodingtype=0
				// }
				if (this.pageNumber > 1) {
					this.list = this.list.concat(res.result.records); //将数据拼接在一起
				} else {
					this.list = res.result.records
				}
				uni.hideLoading()
			},
			open(id) {
				console.log('id+++', id)
				this.jackpotId = id
				this.pageNumber = 1
				this.getList()
				this.isShow = true
				this.$refs.popup.open()
			},
			back() {
				// this.isShow = false
				this.$refs.popup.close()
			},
			scrolltolower() {
				console.log("触底了", this.pageNumber, Math.ceil(this.listTotal / this.pageSize), this.listTotal)
				if (this.pageNumber >= Math.ceil(this.listTotal / this.pageSize)) {
					console.log('没有分页')
					// this.lodingtype = 1
				} else {
					// this.lodingtype = 0
					this.pageNumber++; //每触底一次 page + 1;
					this.getList();
				}
			},
		},
	}
</script>

<style>
	view {
		box-sizing: border-box;
	}

	.main {
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		z-index: 10;
		background: rgba(0, 0, 0, 0.6);
		display: flex;
		justify-content: center;
		padding-top: 200rpx;
	}

	.main_box {
		background: #fff;
		border-radius: 16rpx;
		height: 994rpx;
		width: 612rpx;
		border-radius: 16rpx;
		/* transform: scale(0); */
		/* animation: domainactive 0.4s forwards ease-in-out; */
	}

	@keyframes domainactive {
		0% {
			transform: scale(0);
		}

		100% {
			transform: scale(1);
		}
	}

	.main_box_d {
		width: 100%;
		height: 100%;
		background: linear-gradient(180deg, #E5EEFF 3.7%, rgba(255, 255, 255, 0) 86.77%);
		padding: 0 50rpx;
		border-radius: 16rpx;
	}

	.title {
		width: 100%;
		text-align: center;
		font-size: 36rpx;
		color: #222222;
		padding: 40rpx 0;
	}

	.name_list {
		height: 710rpx;
		border: 2rpx solid #E6E6E6;
	}

	.name_list_head {
		width: 100%;
		height: 70rpx;
		line-height: 70rpx;
		text-align: center;
		font-size: 28rpx;
		color: #333333;
		border-bottom: 2rpx solid #E6E6E6;
	}

	.name_list_detail {
		height: 640rpx
	}

	.scroll_view {
		height: 100%;
		width: 100%;
	}

	.detail_ls {
		width: 100%;
		height: 70rpx;
		line-height: 70rpx;
		text-align: center;
		border-bottom: 2rpx solid #E6E6E6;
	}

	.detail_ls:last-child {
		border-bottom: 0;
	}

	.button_box {
		width: 100%;
		display: flex;
		justify-content: center;
		border-radius: 16rpx;
		margin-top: 40rpx;
	}

	.button_box image {
		width: 204rpx;
		height: 76rpx;
	}
</style>
